#ifndef HTTP_PROTOCOL_OPERATION_H_
#define HTTP_PROTOCOL_OPERATION_H_

#include "protocol_operation.h"
#include "protocol_operation_factory.h"

#include <cstdint>
#include <string>

class HttpResponseProtocolParser;
class HttpRequestProtocolParser;
class HttpRequest;
class HttpResponse;
class HttpProtocolOperation : public ProtocolOperation
{
public:
    enum OpMode
    {
        REQUEST,
        RESPONSE
    };

public:
    HttpProtocolOperation(int mode);
    virtual ~HttpProtocolOperation();
    int            ParserProtocol(const uint8_t * data, int data_length, int & use_length) override;
    HttpRequest *  HttpRequestMsg() const;
    HttpResponse * HttpResponseMsg() const;
    void           ClearMsg() const;
    int            NeedNotFinishProcess() override;
private:
    int                          m_mode            = 0;
    HttpRequestProtocolParser *  m_request_parser  = nullptr;
    HttpResponseProtocolParser * m_response_parser = nullptr;
};

class HttpProtocolOperationFactory : public ProtocolOperationFactory
{
public:
    HttpProtocolOperationFactory() = default;
    ~HttpProtocolOperationFactory() override = default;
    std::shared_ptr<ProtocolOperation> CreateProtocolOperation() override;
};

class HttpProtocolOperationFactoryForReq : public ProtocolOperationFactory
{
    HttpProtocolOperationFactoryForReq() = default;
    ~HttpProtocolOperationFactoryForReq() override = default;
    std::shared_ptr<ProtocolOperation> CreateProtocolOperation() override;
};

#endif
